Skip to content

Set setting_sources=[] to stop duplicating the prompt bundle#179

Merged
pufit merged 1 commit into
mainfrom
serxa/dedupe-identity-bundle
Jul 17, 2026
Merged

Set setting_sources=[] to stop duplicating the prompt bundle#179
pufit merged 1 commit into
mainfrom
serxa/dedupe-identity-bundle

Conversation

@serxa

@serxa serxa commented Jul 17, 2026

Copy link
Copy Markdown
Member

Problem

Nerve builds the entire system prompt itself: the identity/memory bundle (SOUL/IDENTITY/USER/AGENTS/TOOLS/MEMORY) is injected via system_prompt, and permissions (can_use_tool), MCP servers (mcp_servers), hooks and env are all passed explicitly to ClaudeAgentOptions.

With setting_sources left at its default, the Claude Code CLI additionally loads filesystem settings/memory — including ~/.claude/CLAUDE.md, which is the very same bundle the Claude Code renderer writes for external claude-code use. The result is the identity/memory bundle appearing twice in context — tens of thousands of duplicated tokens on every turn.

Fix

Pass setting_sources=[] in the Claude backend's ClaudeAgentOptions, disabling all filesystem-based settings/memory loading. Nerve owns the whole prompt, so there is nothing legitimate to load from disk.

Why [] and not ["project"]

An earlier attempt to drop only the user-level CLAUDE.md with ["project"] is insufficient: the managed workspace lives under $HOME, so the CLI's project-root detection climbs to $HOME and loads ~/.claude/CLAUDE.md under both the "user" and "project" sources. Only the empty list removes it entirely.

Native skills/plugins are unaffected — they load via plugins (--plugin-dir), independent of setting_sources.

Verification

  • Confirmed on the SDK path that ["project"] and ["user"] both re-inject the bundle while [] does not (the emitted --setting-sources= is parsed as "none", not the default ["user","project"]).
  • Full test suite green: 1547 passed, 2 skipped.
  • Verified live in a running session: no claudeMd context block, native skills still present.

Nerve builds the entire system prompt itself — the identity/memory bundle (SOUL/IDENTITY/USER/AGENTS/TOOLS/MEMORY) via system_prompt, plus permissions, MCP servers, hooks and env passed explicitly. Left at the default, the Claude Code CLI also auto-loads ~/.claude/CLAUDE.md (the bundle its own renderer writes for external claude-code use), duplicating tens of thousands of tokens on every turn.

Passing setting_sources=[] disables all filesystem settings/memory loading. ["project"] alone is insufficient: the managed workspace lives under $HOME, so project-root detection climbs to $HOME and loads the user-level CLAUDE.md under both the "user" and "project" sources. Native skills/plugins are unaffected (loaded via plugins / --plugin-dir).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pufit
pufit merged commit 4f8b18a into main Jul 17, 2026
2 checks passed
@pufit
pufit deleted the serxa/dedupe-identity-bundle branch July 17, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants